from pyg2plot import Plot

data = [
  { "year": "1951 年", "value": 38 },
  { "year": "1952 年", "value": 52 },
  { "year": "1956 年", "value": 61 },
  { "year": "1957 年", "value": 145 },
  { "year": "1958 年", "value": 48 },
]

set_options = {
  "appendPadding": 32,
  "data": data,
  "xField": "value",
  "yField": "year",
  "seriesField": "year",
  "legend": False
}

def render_html(data="", set_options=set_options):
  if data == "":
    pass
  else:
    set_options['data'] = data
    
  bar = Plot("Bar")
  bar.set_options(set_options)
  return bar.render_html()

def example_params(data=data,set_options=set_options):
  return {'data':data,'set_options':set_options}